-- queen_ummoner
-- create by cheny3
-- 技能: 黑白皇后召唤

return {
    apply = function(source, target, skillId, round, para, extra)
        if #para ~= 3 then
            return {};
        end

        -- 如果不是怪物，或者已经死亡了
        if source.type ~= OBJECT_TYPE_MONSTER or source:isDead() then
            return {};
        end

        -- 选择召唤怪
        local element = para[2];
        local rule = para[1];
        if rule == "evil_statue" then
            -- 精英怪
            element = para[3];
        else
            -- 默认召出第一个
            element = para[2];
        end

        -- 最多召唤2个
        local callNum = 2 - DungeonM.getElementNum(element);
        if callNum <= 0 then
            return {};
        end

        for i = 1, callNum do
            local arr = DungeonM.findEmptyGrids();
            -- 如果没有空位了
            if #arr <= 0 then
                return { source, };
            end

            local rand = DungeonM.getRandSeed("summoner_skill");
            local pos = arr[rand % #arr + 1];

            -- 召唤一个怪物
            DungeonM.transGridToMonster(pos, element);
        end

        return { source, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        local ret = {arr[1], tonumber(arr[2]), tonumber(arr[3])};

        return ret;
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        return desc;
    end,
}

